<template>
  <el-table
    :data="tableData6"
    :span-method="objectSpanMethod"
    border
    style="width: 100%; margin-top: 20px"
   size="mini">
    <el-table-column prop="layer" label="楼层" width="180"></el-table-column>
    <el-table-column prop="roomNum" label="房号"></el-table-column>
    <el-table-column prop="apartment" label="户型"></el-table-column>
    <el-table-column prop="measure" label="面积（平米）"></el-table-column>
    <el-table-column prop="type" label="房屋类型"></el-table-column>
    <el-table-column prop="orientation" label="朝向"></el-table-column>
    <el-table-column label="操作" width="180">
      <template slot-scope="scope">
        <el-button type="text" size="small" @click="roomDetail(scope.row)">详细数据</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
export default {
  data() {
    return {
      tableData6: [
        {
            layer:'1f',
            roomNum:'101',
            apartment:"2室1厅1卫1阳",
            measure:"160",
            type:"平层",
            orientation:"南"
        },{
            layer:'1f',
            roomNum:'101',
            apartment:"2室1厅1卫1阳",
            measure:"160",
            type:"平层",
            orientation:"南"
        },{
            layer:'1f',
            roomNum:'101',
            apartment:"2室1厅1卫1阳",
            measure:"160",
            type:"平层",
            orientation:"南"
        },{
            layer:'1f',
            roomNum:'101',
            apartment:"2室1厅1卫1阳",
            measure:"160",
            type:"平层",
            orientation:"南"
        },{
            layer:'1f',
            roomNum:'101',
            apartment:"2室1厅1卫1阳",
            measure:"160",
            type:"平层",
            orientation:"南"
        },{
            layer:'1f',
            roomNum:'101',
            apartment:"2室1厅1卫1阳",
            measure:"160",
            type:"平层",
            orientation:"南"
        }
      ],
      spanArr:[],
      housesId: "",
    };
  },
  created(){
    
  },
  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    },
    roomNumber() {
      this.$router.push({
        path: "roomNumber"
      });
    },
    roomDetail(row){
        this.$root.$emit("roomDetail",'no',row)
    },
    selectList(obj) {
      //列表请求
      let url = "houses/unit";
      let that = this; //解决this指向问题
      request.ajaxGet({
        url,
        that,
        params: obj,
        fn(res) {
          if(res){
            var dataList = [];
            let arr=[]
            let contactDot = 0;
            for(let i=0,len=res.length;i<len;i++){
              for(let j=0,leng=res[i].list.length;j<leng;j++){
                dataList.push(res[i].list[j])
                if(j=='0'){
                  arr.push(res[i].size)
                }else{
                  arr.push(0)
                }
              }
            }
            for (let i = 0, len = dataList.length; i < len; i++) {
              if (dataList[i].stairsType) {
                dataList[i].stairsType = dataList[i].stairsType.split("-");
                dataList[i].stairsType = dataList[i].stairsType[0] + "梯" + dataList[i].stairsType[1] + "户";
              }
            }
            that.spanArr=arr
            that.gridData = dataList;
          }else{
            that.gridData =[]
          }
        }
      });
    }
  }
};
</script>

